package com.dove.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dove.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
//    @Insert("insert into sys_user(username,password,nickname,email,phone,address) values(#{username},#{password},#{nickname},#{email},#{phone},#{address})")
    int insertUser(User user);

    Integer deleteUserById(Integer id);
//    @Update("update sys_user set username=#{username},password=#{password} where id=#{id}")
    Integer updateUser(User user);
    @Select("select * from sys_user")
    List<User> selectAll();

    User selectUserById(Integer id);
//username、phone
    List<User> selectByKeyword(Object keyword);

    @Select("select * from sys_user limit #{pageNum},#{pageSize}")
    List<User> mySelectPage(Integer pageNum,Integer pageSize);

    @Select("select count(*) from sys_user")
    Integer selectTotal();

    Page<User> myFindPage(Page<User> page, @Param("username") String username, @Param("nickname") String nickname,@Param("address") String address);
}

